
def getRadius(vl, vr, d):
    if abs(vr-vl)<1e-6:
        return float('inf')
    else:
        return d*(vl+vr)/(vr-vl)
    
def getP(R,d):
    if abs(R+d)<1e-6:
        return float('inf')
    else:
        return (R-d)/(R+d)
def sgn(x):
    if x>0:
        return 1
    elif x<0:
        return -1
    else:
        return 0


def radius_adjust_self(vl, vr, d,delta):
    S= abs(vl) + abs(vr)
    
    cur_R=getRadius(vl, vr, d)
    new_R=cur_R + delta if cur_R!=float('inf') else delta
    
    if abs(new_R)>1e6:#直行
        return S/2, S/2
    elif abs(new_R)<1e-6:#原地
        if vr > vl:#左转
            return -S/2, S/2
        else:#右转
            return S/2, -S/2
    
    p=getP(new_R, d)
       
    new_vl=0
    new_vr=0
    
    if p>0:
        new_vr=S/(1+p)
        new_vl=p*new_vr
    elif p<0:
        new_vr=S/(1-p)*sgn(new_R)
        new_vl=p*new_vr

    
    
    
    
   
    
        
        
    
    
    print(f"cur_R:{cur_R}, new_R:{new_R}")
    
radius_adjust_self(1,1,1,1)
        
    
    